﻿using Enyim.Caching;
using Ayatta.Contract;
using System.Web.Mvc;
using Ayatta.Contract.Domain;
using Web.Base.Extensions;
using Web.Manage.Controllers;
using Web.Manage.Areas.Auction.Models;

namespace Web.Manage.Areas.Auction.Controllers
{
    public class ShareController : AdminBaseController
    {

        public ShareController(ILogService logService, IBaseService baseService, IExtraService extraService, IStoreService storeService, IOrderService orderService, IGameService gameService, IAuctionService auctionService, IPassportService passportService, IPaymentService paymentService, IMemcachedClient memcachedClient)
            : base(logService, baseService, extraService, storeService, orderService, gameService, auctionService, passportService, paymentService, memcachedClient)
        {
        }

        public ActionResult Index(int page = 1, int size = 2, string keyword = null, int? auctionId = null, AuctionShareStatus? status = null)
        {
            var model = new ShareControllerModel.Index();
            int userId;
            string userName;
            if (int.TryParse(keyword, out userId))
            {
                userName = null;
                model.Keyword = userId.ToString();
            }
            else
            {
                userName = keyword;
                model.Keyword = userName;
            }
            model.AuctionId = auctionId;
            model.Status = status;
            model.AuctionShares = AuctionService.GetPagedAuctionShares(page, size, userId, userName, auctionId, status).ToPagedList(page, size);
            return PartialView(model);
        }
    }
}
